package com.leapp.sk.viewdelegate.adapter.classs

import android.content.Context
import android.content.Intent
import android.text.TextUtils
import android.view.View
import android.widget.TextView
import com.example.mvp.delegate.BaseAdapterDelegate
import com.example.mvp.view.NoScrollGridView
import com.leapp.sk.R
import com.leapp.sk.bean.AlbumEntity
import com.leapp.sk.bean.ClassAlbumDetialEntity
import com.leapp.sk.bean.ClassAlbumEntity
import com.leapp.sk.ui.activity.classs.ClassAlbumPreviewActivity
import com.leapp.sk.ui.adapter.ClassAlumDetialImageAdapter

/**
 * 班级相册详情文本适配器视图托管
 * @author  chaohaipeng  on 2018/8/6.
 */
class ClassAlbumDetialTextAdapterDelegate : BaseAdapterDelegate() {
    override fun getOptionsMenuId(): Int {
        return 0
    }

    override fun initWidget() {
    }

    override fun onDestroy() {
    }

    override fun initLayoutRes(): Int {
        return R.layout.adapter_class_album_detial_text
    }

  fun  initData(context: Context,data: ClassAlbumDetialEntity){
      val gv_acad_image = getView<NoScrollGridView>(R.id.gv_acad_image)
      val tv_cad_time = getView<TextView>(R.id.tv_cad_time)
      val image = data.image
      if (image!!.size>0){
          gv_acad_image.visibility= View.VISIBLE
          val classAlumDetialImageAdapter = ClassAlumDetialImageAdapter(context, image)
          gv_acad_image.adapter=classAlumDetialImageAdapter
      }else{
          gv_acad_image.visibility= View.GONE
      }
        if (!TextUtils.isEmpty(data.time)){
            tv_cad_time.text=data.time
        }
      gv_acad_image.setOnItemClickListener{adapterView, view, i, l ->
          run {
              val intent = Intent(context, ClassAlbumPreviewActivity::class.java)
              context.startActivity(intent)
          }
      }


    }


}